﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using MyFinanceManager.Controls;

namespace MyFinanceManager
{
    public partial class ucAmount : FiringUserControl
    {
        public double Value
        {
            get
            {
                double value = this.upAndDowner3.Value;
                value += this.upAndDowner2.Value * 10;
                value += this.upAndDowner1.Value * 100;
                value += this.upAndDowner0.Value * 1000;
                value += (double)this.upAndDowner4.Value / 10;
                value += (double)this.upAndDowner5.Value / 100;
                return value;
            }
        }

        public ucAmount()
        {
            InitializeComponent();

            this.upAndDowner0.ValueChanged += new EventHandler(upAndDowner_ValueChanged);
            this.upAndDowner1.ValueChanged += new EventHandler(upAndDowner_ValueChanged);
            this.upAndDowner2.ValueChanged += new EventHandler(upAndDowner_ValueChanged);
            this.upAndDowner3.ValueChanged += new EventHandler(upAndDowner_ValueChanged);
            this.upAndDowner4.ValueChanged += new EventHandler(upAndDowner_ValueChanged);
            this.upAndDowner5.ValueChanged += new EventHandler(upAndDowner_ValueChanged);
        }

        void upAndDowner_ValueChanged(object sender, EventArgs e)
        {
            FireNewValueAvailable(this.Value.ToString("C"));
        }

    }
}
